Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheduler #395

Merged
merged 9 commits into from
Dec 29, 2023
Merged

Add scheduler #395

merged 9 commits into from
Dec 29, 2023

Conversation

small-turtle-1
Copy link
Contributor

@small-turtle-1 small-turtle-1 commented Dec 28, 2023

What problem does this PR solve?

Refactor the scheduler.

Issue link:
#387

What is changed and how it works?

  1. Remove coordinate thread.
  2. Determine init fragments in TaskScheduler::Schedule. Init fragments are leaf fragments.
  3. In TaskScheduler::WorkerLoop, when a fragment task finished, if FragmentTask::IsComplete return true, FragmentTask::CompleteTask is called, which calls FragmentContext::TryFinishFragment. The latter reduce the unfinished_task_n_ in FragmentContext and when it is 0, it reduce its parent FragmentContext's unfinished_child_n_ by FragmentContext::TryStartFragment. If it returns true, then schedule that parent fragment by TaskScheduler::ScheduleFragment.
  4. For FragmentType::kParallelStream, the return value of FragmentContext::TryStartFragment will be ignored, and all its parent tasks that not in work loop can be scheduled in.
  5. And for FragmentType::kParallelStream, if FragmentContext::TryFinishFragment return false, the task souce will be checked if there is more data. If not, this task will be scheduled out.

Code changes

  • Has Code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

@JinHai-CN JinHai-CN merged commit ada746c into infiniflow:main Dec 29, 2023
2 of 3 checks passed
@small-turtle-1 small-turtle-1 deleted the add_scheduler branch December 29, 2023 03:30
small-turtle-1 added a commit to small-turtle-1/infinity that referenced this pull request Jan 3, 2024
* tmp schedule strategy.

* Add scheduler when fragment task finished.

* Prevent stream operator dead loop.

* Fix bug of not finishing.

* Replace create index source and sink operator.

* Fix bug that source operator of stream fragment is not kQueue.

* Fmt.

* Fix: check if task is already in worker loop in TaskScheduler::ScheduleFragment.

* Feat: add simple cpu affinity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants